<?php

class Helper_TinyMCE
{
    public $view;
    
    public function setView(Zend_View_Interface $view)
    {
        $this->view = $view;
    }

    function tinyMCE()
    {
        // initializing TinyMCE
        if (function_exists('gzencode'))
        {
            $this->view->headScript()->appendFile($this->view->baseUrl('js/tinymce/jscripts/tiny_mce/tiny_mce_gzip.js'));
            $this->view->headScript()->appendFile($this->view->baseUrl('js/tinymce/init_gzip.js'));
            $this->view->headScript()->appendFile($this->view->baseUrl('js/tinymce/init.js'));
        } else 
        {
            $this->view->headScript()->appendFile($this->view->baseUrl('js/tinymce/jscripts/tiny_mce/tiny_mce.js'));
            $this->view->headScript()->appendFile($this->view->baseUrl('js/tinymce/init.js'));
        }
        
        $lang=file_exists(ROOT_DIR.'/js/tinymce/jscripts/tiny_mce/langs/'.quotemeta(Zend_Registry::get('locale')->getLocale()).'.js') ? Zend_Registry::get('locale')->getLocale() : 'en';
        $this->view->headScript()->captureStart();
        echo 'tinymce_site="'.$this->view->siteUrl().'"; tinymce_lang="'.$lang.'";';
        $this->view->headScript()->captureEnd();
    }
}